package com.stars.services.impl.quartz.jobs;

import com.stars.common.MyDateUtils;
import com.stars.common.db.MySQLDatabaseBackup;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Component("backDb")
@Transactional
public class BackDb {
    @Value("${spring.datasource.username}")
    private String username;
    @Value("${spring.datasource.password}")
    private String password;
    @Value("${spring.datasource.ip}")
    private String ip;
    @Value("${spring.datasource.dbName}")
    private String dbName;
    @Value("${spring.datasource.dbBkPath}")
    private String dbBkPath;
    /**
     * 备份数据
     * @throws Exception
     */
    public void executeBackupDb() throws Exception {
        MySQLDatabaseBackup.exportDatabaseTool(ip,username,password,dbBkPath, MyDateUtils.getCurrentYear()+"_bk.sql",dbName);
    }
}
